#ifndef __THREAD_POOL_H__
#define __THREAD_POOL_H__
#pragma once
#define MAX_TESK_NUM        50
#define MAX_THREAD_NUM      50


#include <unistd.h>
#include <pthread.h>

#include <iostream>
using namespace std;

typedef void *(* Tesk)(void *);


class ThreadPool {
private:
    typedef void *(* Thread)(void *);

    typedef unsigned int    uint32_t;
    typedef signed int      int32_t;
    typedef unsigned short  uint16_t;
    typedef signed short    int16_t;
    typedef unsigned char   uint8_t;
    typedef signed char     int8_t;

    uint32_t teskHead = 0;
    uint32_t teskTail = 0;
    uint32_t teskNum = 0;
    Tesk TesksList[MAX_TESK_NUM];
    void const * ArgsList[MAX_TESK_NUM];
    pthread_mutex_t mutex;
    pthread_cond_t cond;

private:
    static ThreadPool *mPOOL;
    ThreadPool();
    ~ThreadPool();
    ThreadPool(const ThreadPool&) = delete;
    ThreadPool &operator=(const ThreadPool&) = delete;

public: 
    friend void *Thread_Pool_Schedule(void *arg);
    static ThreadPool *getInstance();
    bool start(void);
    bool addTesk(const Tesk ptesk, const void *arg);
    uint32_t getTestNum();
};







#endif //__THREAD_POOL_H__